<?php

namespace app\webapi\vms\model;

use app\webapi\common\BaseModel;

/**
 * @文章模型
 */
class ArticleModel extends BaseModel
{
    //定义数据表名
    protected $table = 'jq_website_article';
    //定义前缀
    protected $suffix = '';

    /**
     * @desc 设置后缀名(用于垂直分表)
     * @param string $suffix
     * @return ArticleModel
     * @author zhaozhiwei
     * @time 2023/12/19-14:22
     */
    public function setSuffix(string $suffix)
    {
        $suffix = '';
        if (false) {
            $suffix = '_' . $suffix % 2;
            return parent::setSuffix($suffix);
        }
        return parent::setSuffix($suffix);
    }

    /**
     * @desc 状态获取器
     * @param $value
     * @param $data
     * @return string
     * @author zhaozhiwei
     * @time 2023/12/19-14:22
     */
    public function getStatusTextAttr($value, $data)
    {
        $status = [0 => '待发布', 1 => '已发布', 2 => '已禁用'];
        return $status[$data['status']];
    }

    /**
     * @desc 是否首页显示获取器
     * @param $value
     * @param $data
     * @return string
     * @author zhaozhiwei
     * @time 2023/12/19-14:22
     */
    public function getIsShowIndexTextAttr($value, $data)
    {
        $status = [0 => '否', 1 => '是'];
        return $status[$data['is_show_index']];
    }

    /**
     * @desc 是否列表显示获取器
     * @param $value
     * @param $data
     * @return string
     * @author zhaozhiwei
     * @time 2023/12/19-14:22
     */
    public function getIsShowListTextAttr($value, $data)
    {
        $status = [0 => '否', 1 => '是'];
        return $status[$data['is_show_list']];
    }

}